package com.app.view.component.dialogs.pkResultView 
{
	import flash.display.MovieClip;
	
	import com.app.model.data.PaijiuTypeItemData;
	
	import com.peachcastle.core.Display;
	import org.component.Hlist;
	import com.app.view.component.dialogs.pkResultView.PaijiuTypeListItem;
	import com.app.view.component.room.seat.PaijiuType;
	
	/**
	 * ...
	 * @author kevin
	 */
	public class PaijiuTypeList extends Display
	{
		private var _list:Hlist = null;
		private var _listData:Array = [];
		
		public function PaijiuTypeList(ui:MovieClip = null) 
		{
			super(ui);
		}
		
		override protected function initialization():void 
		{
			super.initialization();
			
			_list = new Hlist(assest, PaijiuTypeListItem, 8, 27);
			initPaijiuType();
			
		}
		
		private function initPaijiuType():void
		{
			var len:int = PaijiuType.TYPES.length;
			for (var i:int = 0; i < len; i++)
			{
				for (var j:String in PaijiuType.TYPES[i])
				{
					var p:PaijiuTypeItemData = new PaijiuTypeItemData();
					p.rank = String(i + 1);
					p.title = PaijiuType.TYPES[i][j];
					
					p.paijiu_1 = int(j.substr(0, j.length / 2));
					
					p.paijiu_2 = int(j.substr(j.length/2, j.length));
					
					_listData[i] = p;
					
					p = null;
				}
			}
		}
		
		public function setUserPaijiu(rank:int, str:String, type:String = '', paijiu_1:int = 0, paijiu_2:int = 0):void
		{	
			if(rank > 0 && rank < _listData.length)
			{
				PaijiuTypeItemData(_listData[rank]).rank = str;
				PaijiuTypeItemData(_listData[rank]).isUserPaijiu = true;
			}else
			{
				var p:PaijiuTypeItemData = new PaijiuTypeItemData();
				p.rank = str;
				p.title = type;
				p.paijiu_1 = paijiu_1;
				p.paijiu_2 = paijiu_2;
				p.isUserPaijiu = true;
				_listData[_listData.length] = p;
				
				p = null;
			}
		}
		
		public function update():void
		{
			_list.update(_listData);
		}
	}

}